import request from '@/utils/request'

export function login(name, password) {
  return request({
    url: '/teacher/login',
    method: 'post',
    data: {
      name,
      password
    }
  })
}
export function logout(username, password) {
  return request({
    url: '/teacher/logout',
    method: 'post',
    data: { }
  })
}
export function getDashboardInfo() {
  return request({
    url: '/teacher/getDashboardInfo',
    method: 'post',
    data: { }
  })
}

export function getTeacherList(data) {
  return request({
    url: '/teacher/getTeacherList',
    method: 'post',
    data: {
      currentpage: data.currentpage,
      pagesize: data.pagesize,
      name:  data.name,
    }
  })
}
export function getAllTeacher(data) {
  return request({
    url: '/teacher/getAllTeacher',
    method: 'post',
    data: {
    }
  })
}
export function getStudentList(data) {
  return request({
    url: '/teacher/getStudentList',
    method: 'post',
    data: {
      currentpage: data.currentpage,
      pagesize: data.pagesize,
      name:  data.name,
    }
  })
}
export function getClassRoomList(data) {
  return request({
    url: '/teacher/getClassRoomList',
    method: 'post',
    data: {
      currentpage: data.currentpage,
      pagesize: data.pagesize,
      name:  data.name,
    }
  })
}
export function getAllClassRoom(data) {
  return request({
    url: '/teacher/getAllClassRoom',
    method: 'post',
    data: {
    }
  })
}
export function updateClassroom(data) {
  return request({
    url: '/teacher/updateClassroom',
    method: 'post',
    data
  })
}


export function addTeacher(data) {
  return request({
    url: '/teacher/addTeacher',
    method: 'post',
    data: {
      name:data.name,
      password:data.password,
      subject:data.subject,
    }
  })
}


export function addClassroom(data) {
  return request({
    url: '/teacher/addClassroom',
    method: 'post',
    data: {
      name:data.name,
      place:data.place,
      kebiao:data.kebiao,
      starttime:data.starttime,
      endtime:data.endtime,
      mtid:data.mtid,
    }
  })
}

export function getAllPaperList(data) {
  return request({
    url: '/teacher/getAllPaperList',
    method: 'post',
    data: {
      currentpage: data.currentpage,
      pagesize: data.pagesize,
      name:  data.name,
    }
  })
}
export function getQuestionList(data) {
  return request({
    url: '/teacher/getQuestionList',
    method: 'post',
    data: {
      currentpage: data.currentpage,
      pagesize: data.pagesize,
      name:  data.name,
    }
  })
}
export function getStudengQiandao(id) {
  return request({
    url: '/teacher/getStudengQiandao',
    method: 'post',
    data: {
      id:id
    }
  })
}

export function getAnswerList(data) {
  return request({
    url: '/teacher/getAllPaperList',
    method: 'post',
    data: {
      currentpage: data.currentpage,
      pagesize: data.pagesize,
      name:  data.name,
    }
  })
}


export function addStudent(data) {
  return request({
    url: '/teacher/addStudent',
    method: 'post',
    data: {

      name:data.name,
      password:data.password,
      cid:data.cid,
      realname:data.realname,
    }
  })
}

export function addPaper(data) {
  return request({
    url: '/teacher/addPaper',
    method: 'post',
    data: {

      name:data.name,
      createtime:data.createtime,
      endtime:data.endtime,
      tid:data.tid,
      cid:data.cid,
      totalscore:data.totalscore,
      img:data.img,
      questions: JSON.stringify( data.question),
    }
  })
}

export function addQuestion(data) {
  return request({
    url: '/teacher/addQuestion',
    method: 'post',
    data: {
      question:data.question,
      type:data.type,
      realanswer:data.answer,
      answer1:data.answer1.label,
      answer2:data.answer2.label,
      answer3:data.answer3.label,
      answer4:data.answer4.label,
      score:data.score,
    }
  })
}





export function getMyClassRoomInfo(username, password) {
  return request({
    url: '/teacher/getMyClassRoomInfo',
    method: 'post',
    data: { }

  })
}

export function getMyInfo(username, password) {
  return request({
    url: '/teacher/getMyInfo',
    method: 'post',
    data: { }

  })
}
export function changepass() {
  return request({
    url: '/teacher/changepass',
    method: 'post',
    data: { }

  })
}

export function getAllAnswerResultList(data) {
  return request({
    url: '/teacher/getAllAnswerResultList',
    method: 'post',
    data: {
      currentpage: data.currentpage,
      pagesize: data.pagesize,
      name:  data.name,
    }
  })
}

